package ru.jetsoft.reg112.desktop.control;

import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import ru.jetsoft.reg112.desktop.data.Param;

public class GroupControl extends BaseGroupControl {

    private final VBox groupBox;

    public GroupControl(Param param) {
        super(param);
        Text title = new Text(param.getName());
        title.setFont(Font.font("System", FontWeight.BOLD, 13));
        groupBox = new VBox();
        groupBox.setSpacing(5);
        groupBox.setPadding(new Insets(2, 2, 2, 2));
        groupBox.setStyle("-fx-border-style: solid;"
                        + "-fx-border-width: 1;"
                        + "-fx-border-color: lightgray");
        getVBox().setAlignment(Pos.TOP_LEFT);
        getVBox().getChildren().addAll(title, groupBox);
    }

    @Override
    protected void refresh() {
        groupBox.getChildren().clear();
        for(ControlContainer child: getChilds()) {
            groupBox.getChildren().add(child.getNode());
        }
    }
}
